How to show a linked object only once

Hi there, I'm working with the built in Recursive Traceability script to show 2 levels of links. So, we have Module A, showing outlinks to Module B in column 1, and then the recursive links from Module B to Module C in Column 2. Here is an example of how the links work:

Module A
Object 10 --> Module B, Objects 100, 105, 110.

Module B
Object 100 --> Module C Object 200
Object 105 --> Module C Object 210
Object 110 --> Module C Object 200

So, this is yielding a result where in Column 2 it is showing the following output:
200
210
200

What I would like is to make it so that object 200 does not appear again once it has already shown up. I am guessing this would be done using an array but I haven't been able to figure it out. Any help would be appreciated!

Mike
Mike_the_SE - Wed Nov 14 12:59:39 EST 2012

Re: How to show a linked object only once
llandale - Wed Nov 14 13:37:32 EST 2012

Where you finally display info of object in C, instead put the "Object" handle into a global skip list. After parsing all the links then loop through the Skip displaying info of each object therein.

Skip skpObjects = createString() // KEY 'string' ObjID; DATA: 'Object' handle in C
void DisplayInfo()
{  for o in skpObjects do
   {  "Display" info about o
   }
}
 
void Whatever(int depth)
{  for links from A to C
   {  bla bla bla
      find othero object in C
      // comment out the "s" and "display" lines
      put(skpObjects, identifier(othero), othero)
   }
}
Whatever(2)
DisplayInfo()
delete(skpObjects)


The idea is that the 2nd time you encounter a particular C object, the duplicate "put" is ignored.
-Louie

Re: How to show a linked object only once
Mike_the_SE - Wed Nov 14 13:51:18 EST 2012

llandale - Wed Nov 14 13:37:32 EST 2012

Where you finally display info of object in C, instead put the "Object" handle into a global skip list. After parsing all the links then loop through the Skip displaying info of each object therein.

Skip skpObjects = createString() // KEY 'string' ObjID; DATA: 'Object' handle in C
void DisplayInfo()
{  for o in skpObjects do
   {  "Display" info about o
   }
}
 
void Whatever(int depth)
{  for links from A to C
   {  bla bla bla
      find othero object in C
      // comment out the "s" and "display" lines
      put(skpObjects, identifier(othero), othero)
   }
}
Whatever(2)
DisplayInfo()
delete(skpObjects)


The idea is that the 2nd time you encounter a particular C object, the duplicate "put" is ignored.
-Louie

Hi Louie,

I understand the point you are making, but I'm not sure exactly how to fit it into the code. My code is attached:
 

// DXL generated by DOORS traceability wizard on 31 October 2012.
// Wizard version 2.0, DOORS version 9.2.0.4
pragma runLim, 0
string limitModules[2] = {"471615b43d9013d6-000018e1", "471615b43d9013d6-00001ea2"}
int lines[2] = {0, 0}
void adjustLines(int depth, showAtDepth) {
    int count
    for (count = 0; count < 2; count++) {
        while (lines[depth-1] < lines[count]) {
            if (depth == showAtDepth) displayRich("\\pard " " ")
            lines[depth-1]++
        }
    }
}
void showOut(Object o, int depth) {
    Link l
    LinkRef lr
    ModName_ otherMod = null
    Module linkMod = null
    ModuleVersion otherVersion = null
    Object othero
    string disp = null
    string s = null
    string plain, plainDisp
    int plainTextLen
    int count
    bool doneOne = false
    string linkModName = "*"
    for l in all(o->linkModName) do {
        otherVersion = targetVersion l
        otherMod = module(otherVersion)
        if (null otherMod || isDeleted otherMod) continue
        if (!equal(getItem otherMod, (itemFromID limitModules[depth-1]))) continue
        othero = target l
        if (null othero) {
            load(otherVersion,false)
        }
        othero = target l
        if (null othero) continue
        if (isDeleted othero) continue
        adjustLines(depth, 2)
        if (depth < 2) {
            showOut(othero, depth+1)
        }
        doneOne = true
        if (depth == 2) {
            disp = ""
            s = probeRichAttr_(othero,"Absolute Number", true)
            disp = disp s
            s = probeRichAttr_(othero,"Object Heading", true)
            disp = disp  " " s
            displayRich("\\pard " disp)
        }
        lines[depth-1]++
    }
}
showOut(obj,1)


Sorry for my inexperience, I haven't dealt with skip lists before.

Re: How to show a linked object only once
llandale - Wed Nov 14 15:12:31 EST 2012

Mike_the_SE - Wed Nov 14 13:51:18 EST 2012

Hi Louie,

I understand the point you are making, but I'm not sure exactly how to fit it into the code. My code is attached:
 

// DXL generated by DOORS traceability wizard on 31 October 2012.
// Wizard version 2.0, DOORS version 9.2.0.4
pragma runLim, 0
string limitModules[2] = {"471615b43d9013d6-000018e1", "471615b43d9013d6-00001ea2"}
int lines[2] = {0, 0}
void adjustLines(int depth, showAtDepth) {
    int count
    for (count = 0; count < 2; count++) {
        while (lines[depth-1] < lines[count]) {
            if (depth == showAtDepth) displayRich("\\pard " " ")
            lines[depth-1]++
        }
    }
}
void showOut(Object o, int depth) {
    Link l
    LinkRef lr
    ModName_ otherMod = null
    Module linkMod = null
    ModuleVersion otherVersion = null
    Object othero
    string disp = null
    string s = null
    string plain, plainDisp
    int plainTextLen
    int count
    bool doneOne = false
    string linkModName = "*"
    for l in all(o->linkModName) do {
        otherVersion = targetVersion l
        otherMod = module(otherVersion)
        if (null otherMod || isDeleted otherMod) continue
        if (!equal(getItem otherMod, (itemFromID limitModules[depth-1]))) continue
        othero = target l
        if (null othero) {
            load(otherVersion,false)
        }
        othero = target l
        if (null othero) continue
        if (isDeleted othero) continue
        adjustLines(depth, 2)
        if (depth < 2) {
            showOut(othero, depth+1)
        }
        doneOne = true
        if (depth == 2) {
            disp = ""
            s = probeRichAttr_(othero,"Absolute Number", true)
            disp = disp s
            s = probeRichAttr_(othero,"Object Heading", true)
            disp = disp  " " s
            displayRich("\\pard " disp)
        }
        lines[depth-1]++
    }
}
showOut(obj,1)


Sorry for my inexperience, I haven't dealt with skip lists before.

I don't have time to code it.
  • You can copy exactly every one of my lines referencing "skpObjects". Once you get "o" from the Skip you don't need to reference the Skip when displaying "o" information.
  • My function "Whatever" I see is function "showOut" below. Existing call "showOut(obj,1)" is correct.
  • The "put" would replace the 6 "disp" lines near the bottom after line "if (depth == 2){".
  • Those 6 lines (or similar) would be moved new function "DisplayInfo()"
  • I don't think function adjustLines() is useful in this context.
  • DisplayInfo() needs "Object o" and other declarations like "string s".

-Louie